const session = require("express-session")

const exp = require("express")

const ejs = require("ejs")

const pageRouter = require("./routers/pageRouter")

const loginRouter = require("./routers/loginRouter")

const noteRouter = require("./routers/notebook")

const app = exp()

app.set("views",__dirname + "/html")
 
app.engine("html",ejs.renderFile)

app.use(session({
    name:"_id",
    secret:"1208",
    saveUninitialized:false,
    resave:false,
    cookie:{
        httpOnly:true,
        maxAge:1000*60*60*60
    }
}))

// 设置中间件
app.use(exp.urlencoded({extended:false}))


app.use(pageRouter)

app.use(loginRouter)

app.use(noteRouter)

app.listen(80,()=>{
    console.log("启动成功");
})